package main

import (
	"encoding/json"
	"fmt"
	"reflect"
)

type NsResponseSt struct {
	Success bool                     `json:"success"`
	Result  []string                 `json:"result"`
	Error   []map[string]interface{} `json:"error"`
}

func main() {
	jsonStr := "{\"success\": false,\"result\": [],\"error\": [{\"message\": \"客户名称必输\",\"data\": {\"type\": \"B端客户\",\"id\": \"C002\",\"country\": \"US\",\"name\": \"\"}}]}"
	NsResponse := NsResponseSt{}
	var data interface{}
	err := json.Unmarshal([]byte(jsonStr), &NsResponse)
	if err != nil {
		fmt.Println(err.Error())
	} else {
		fmt.Println(NsResponse.Error)
		json.Unmarshal([]byte(fmt.Sprintf("%v", NsResponse.Error[0])), &data)
		data=NsResponse.Error[0]["data"]
		typeOf:= reflect.TypeOf(data)
		fmt.Println("typeOf ",typeOf)
		if typeOf.String()=="map[string]interface {}" {
			Map, bool2 := data.(map[string]interface{})
			fmt.Println(bool2)
			fmt.Println(Map["id"])
		}
	}
}
